#include <iostream>

using namespace std;

//计算日期到天数的转换
bool is_leap_year(int year)
{
    return ((year%4==0 && year%100!=0) || year%400==0);
}

int getDay(int year, int moon, int day)
{
    static int moonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    int ans = 0;
    for (int i = 1; i<moon; ++i)
    {
        if (is_leap_year(year) && i==2)
        {
            ans += 29;
        }
        else 
        {
            ans += moonth[i];
        }
    }
    
    ans += day;
    return ans;
    
}

int main()
{
    int year = 0;
    int day = 0;
    int moon = 0;
    cin >> year >> moon >> day;
    
    cout <<  getDay(year, moon, day) << endl;
    
    return 0;
}